package com.glodon.paas.monitor.server.biz.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.glodon.paas.monitor.server.biz.domain.MonitorItemMetaEntity;
import com.glodon.paas.monitor.server.biz.mapper.MonitorItemMetaMapper;
import com.glodon.paas.monitor.server.biz.service.MonitorItemMetaService;
import com.glodon.paas.monitor.server.exception.MonitorException;

@Service("monitorItemMetaService")
public class MonitorItemMetaServiceImpl implements MonitorItemMetaService {

	@Autowired
	private MonitorItemMetaMapper	monitorItemMetaMapper;

	@Override
	public int deleteByPrimaryKey(Long id) {
		if (null == id) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"deleteByPrimaryKey ItemMeta id is null!");
		}
		return monitorItemMetaMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(MonitorItemMetaEntity record) {
		if (null == record || null == record.getItemId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID, "insert ItemMeta record is null!");
		}
		return monitorItemMetaMapper.insert(record);
	}

	@Override
	public int insertSelective(MonitorItemMetaEntity record) {
		if (null == record || null == record.getItemId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"insertSelective ItemMeta record is null!");
		}
		return monitorItemMetaMapper.insertSelective(record);
	}

	@Override
	public MonitorItemMetaEntity selectByPrimaryKey(Long id) {
		if (null == id) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"selectByPrimaryKey ItemMeta id is null!");
		}
		return monitorItemMetaMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(MonitorItemMetaEntity record) {
		if (null == record || null == record.getId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"updateByPrimaryKeySelective ItemMeta record is null!");
		}
		return monitorItemMetaMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(MonitorItemMetaEntity record) {
		if (null == record || null == record.getId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"updateByPrimaryKey ItemMeta record is null!");
		}
		return monitorItemMetaMapper.updateByPrimaryKey(record);
	}

}
